﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Runtime.Versioning;
using System.Xml.Serialization;
using Cubicle.Core.Config;

namespace Cubicle.Nuget.Config
{
    [Serializable]
    [XmlRoot(ElementName = "config")]
    public class NugetConfig : BaseConfig
    {

        [Export] public static readonly NugetConfig Singleton;

        static NugetConfig()
        {
            Singleton = Read<NugetConfig>();
        }

        public bool Overwrite { get { return true; } }
        public FrameworkName MaxFramework { get { return new FrameworkName(".NETFramework", Version.Parse("4.0")); } }

        [XmlElement(ElementName = "AutoUpdate")]                public KvpElement AutoUpdate;
        [XmlElement(ElementName = "feed")]                      public List<FeedElement> Feeds;

    }

    [XmlRoot(ElementName = "feed")]
    public class FeedElement
    {
        [XmlAttribute(AttributeName = "uri")]                   public string Uri;
        [XmlAttribute(AttributeName = "isDefault")]             public bool IsDefault;
        [XmlAttribute(AttributeName = "name")]                  public string Name;

    }
}
